<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
   <%@page import="it.polimi.travelDream.ejb.servlet.*" %>
   <%@page import="it.polimi.travelDream.entities.*" %>
  <jsp:useBean id="hmgr" class="it.polimi.travelDream.ejb.beans.HotelMgr" scope="session" />

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>
		  	TravelDreamLogin
		</title>
		<link rel="stylesheet" type="text/css" href="style.css" />
  	</head>
  
  
  <body>
  	<div class="header">
  		 <ul>
  			<li>TravelDream</li>
		    Manage Basic Products
	    </ul>
  	</div> 	
  	 
  	<div class="section">	    
	    <div class="nav">
	    	<ul>
	    		<li> <a href="StaffHome.jsp">Home</a></li>
	    		<li class="cur"> <a href="BPManagement.jsp"> Manage BasicProducts</a></li>
	    			<ul class="subnav">
						<li><a href="BPAddTransportation.jsp">Add Travel</a></li>
						<li><a href="BPAddHotel.jsp">Add Hotel</a></li>
						<li><a href="BPAddExcursion.jsp">Add Excursion</a></li>
						<li><a href="BPEditTravel.jsp">Edit Transportation</a></li>
						<li class="cur">Edit Hotel &rarr; </li>
						<li><a href="BPEditExcursion.jsp">Edit Excursion</a></li>
					</ul>
	    		<li> <a href="PManagement.jsp"> Manage Packages</a></li>
	    		<% 
	    		Staff z = new Staff(0,false,"0","0","0","0","0");
	      		if (request.getSession().getAttribute("utente")!=null )
		    	{ 
	      			z=(Staff)request.getSession().getAttribute("utente");
		        }
	      		else
	      		{
	      			
	      		}
	    		if (z.isPermission())
	    		{
	    			out.println("<li><a href=StaffRegistration.jsp> Manage Staff </a></li>");
	    		}
		    	
	    
		    		%>
	    		<li> <a href="/TravelDreamSystemWeb/StaffLogoutServlet?session=0"> Logout </a></li>
	    	</ul>
	    </div>
	    <div class="content">
	    <div class="spacer"></div>			
			<div class="spacer"></div> 
			
			        <div class=record>
        			
	        			<div class=recordfield>
	        				Name 
	        			</div>
	        			
	        			<div class=recordfield>
	        				City 
	        			</div>
	        			
	        			<div class=recordfield>
	        				Address 
	        			</div>
	        		
	        			<div class=recordfield>
	        				Availab. 
	        			</div>
	        			
	        			<div class=recordfield>
	        				Type 
	        			</div>
	        			
	        			<div class=recordfield>
	        				Cost 
	        			</div>
	        			
	        			<div class=recordfield>
	        				
	        			</div>
	        			
	        			<div class=recordfield>
	        				 
	        			</div>
        						    	
	    			</div>
			 <%  
        		int i = hmgr.showAllHotels().size() - 1;
				
        		while (i>=0) {
        			out.println("<div class=record>") ;
        			out.println("<form action=EditHotelServlet method=POST>") ;
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=smallinput type=text value="+hmgr.showAllHotels().get(i).getName()+" name=name />");
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=smallinput type=text value="+hmgr.showAllHotels().get(i).getCity()+" name=city />");
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=smallinput type=text value="+hmgr.showAllHotels().get(i).getAddress()+" name=address />");
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=smallinput type=text value="+hmgr.showAllHotels().get(i).getAvailability()+" name=availability />");
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=smallinput type=text value="+hmgr.showAllHotels().get(i).getRumType()+ " name=typeRum />");
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=smallinput type=text value="+hmgr.showAllHotels().get(i).getCostPerDay()+ " name=costPerDay />");
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			
        			out.println("<input name=id type=hidden value="+hmgr.showAllHotels().get(i).getId()+" />");
        			out.println("<input class=smallbutton type=submit value=Save />");
        			out.println("</div>") ;
        			out.println("</form>") ;
        			
        			
        			
        			out.println("<div class=recordfield>") ;
        			out.println("<form action=DelHotel method=POST >") ;
        			out.println("<input type=hidden value="+hmgr.showAllHotels().get(i).getId()+" name=idHotel />");
        			out.println("<input class=smallbutton type=submit value=Del />");
        			out.println("</form>") ;
        			out.println("</div>") ;
        			
        			out.println("</div>");
        			i--;
	    			
        		}
    		%>
			
			
    			   <% 
	    	if (request.getAttribute("message") == null) 
		    	{ 
		    		%>
						<div></div>
					<% 
				} 
	    	else 
		    	{ 
		    		%>
						<div class="advice"><%=request.getAttribute("message")%></div>
					<% 
				} 
		%>
		
		
		
		</div>
    </div>
    
    
    <div class="footer">
    	<ul>
	    	<li>TravelDream Company srl © All rights reserved</li>
		    <li>Terms of use | Contacts | Team </li>
	    </ul>
    </div>  
    
  </body>
</html>